import axios from 'axios';
import imagesMap from '/@/assets/images/images';
import { useMemberOptions } from '/@/views/common/commonSetting';
import { useI18n } from '/@/hooks/web/useI18n';

const { t } = useI18n();
const { memberOptions } = useMemberOptions();

const ipLocation = async (value) => {
  if (!value) {
    console.error('value 为空，终止所有请求');
    return;
  }
  try {
    const response = await axios.get(`https://ipapi.co/${value}/json/`);
    return response.data;
  } catch (error) {
    console.error('请求ip归属地失败', error);
    throw error;
  }
};

export default ipLocation;
export const popColorTabs = ['rgb(99 161 3)', 'rgb(140 150 159)'];
export function getPopIconTabs() {
  // 弹窗图标
  const popIconTabs: TabItem[] = [
    {
      label: '分组1',
      value: '1',
      list: Array.from({ length: 6 }, (_, i) => imagesMap[`bulletin-1_${i + 1}`]),
      identifier: 'bulletin-1_',
    },
  ];
  return popIconTabs;
}
interface TabItem {
  label: string;
  value: number | string;
  list: Array<string>;
  identifier: string;
}

export function useReviewState() {
  const { t } = useI18n();

  const reviewStateAar = [
    { label: t('business.common_all'), value: 0 },
    { label: t('business.common_pending_approval'), value: 1 },
    { label: t('business.common_pending_approval_suceess'), value: 2 },
    { label: t('business.common_pending_approval_reject'), value: 3 },
  ];
  const reviewStateMap = {
    0: '-',
    1: t('business.common_pending_approval'),
    2: t('business.common_pending_approval_suceess'),
    3: t('business.common_pending_approval_reject'),
  };

  return { reviewStateAar, reviewStateMap };
}

export function useAgentreviewState() {
  const { t } = useI18n();

  const agentreviewStateArr = [
    { label: t('business.common_all'), value: 0 },
    { label: t('business.common_pending_approval'), value: 1 },
    // { label: t('business.common_pending_approval_have'), value: 2 },
    { label: t('business.common_suceess'), value: 3 },
    // { label: t('business.common_pending_wait_Received'), value: 4 },
    { label: t('business.common_reject'), value: 5 },
  ];
  const agentreviewStateMap = {
    0: '-',
    1: t('business.common_pending_approval'),
    2: t('business.common_pending_approval_have'),
    3: t('business.common_pending_approval_Received'),
    4: t('business.common_pending_wait_Received'),
    5: t('business.common_reject'),
  };

  return { agentreviewStateArr, agentreviewStateMap };
}

export function useRprofitStateState() {
  const { t } = useI18n();

  const rprofittreviewStateArr = [
    { label: t('business.common_all'), value: 0 },
    { label: t('business.common_pending_approval'), value: 1 },
    // { label: t('business.common_pending_wait_Received'), value: 2 },
    { label: '通过', value: 3 },
    { label: t('business.common_reject'), value: 4 },
    // { label: t('business.Expired'), value: 5 },
    // { label: '待申请', value: 6 },
  ];
  const rprofitreviewStateMap = {
    0: '-',
    1: t('business.common_pending_approval'),
    6: t('business.common_pending_application'),
    2: t('business.common_pending_approval_have'),
    3: '通过',
    4: t('business.common_pending_wait_Received'),
    5: t('business.common_reject'),
    6: '待申请',
  };

  return { rprofittreviewStateArr, rprofitreviewStateMap };
}

export const reviewState = { 0: '-', 1: '待审核', 2: '审核通过', 3: '审核拒绝' };

/** 推广活动的状态 */
export const agentreviewState = {
  0: '-',
  1: '待审核',
  2: '已审核',
  3: '通过',
  4: '待领取',
  5: '拒绝',
};

export const rprofitState = {
  0: '-',
  1: '待审核',
  2: '待领取',
  3: '通过',
  4: '拒绝',
  5: '过期',
  6: '待申请',
};

export const rprofitcolorMap = {
  1: '#f59a23',
  2: '#63a103',
  3: '#63a103',
  4: '#d9001b',
  5: '#d9001b',
  6: '#63a103',
};

export const agentcolorMap = {
  1: '#f59a23',
  2: '#63a103',
  3: '#63a103',
  4: '#d9001b',
  5: '#d9001b',
};

export const colorMap = {
  1: '#f59a23',
  2: '#63a103',
  3: '#d9001b',
};

export const langArr = [
  {
    label: '中文',
    value: 'zh_CN',
  },
  {
    label: '英语',
    value: 'en_US',
  },
  {
    label: '越南语',
    value: 'vi_VN',
  },
  {
    label: '泰语',
    value: 'th_TH',
  },
  {
    label: '葡萄牙语',
    value: 'pt_BR',
  },
  {
    label: '印地语',
    value: 'hi_IN',
  },
];

export const periodList = [
  // {
  //   label: '1天',
  //   value: 86400
  // },
  {
    label: '3天',
    value: 259200,
  },
  {
    label: '7天',
    value: 604800,
  },
  {
    label: t('v.discount.activity.Topup_text6'),
    value: 0,
  },
  {
    label: '自定义',
    value: 5,
  },
];

export const periodListBilling = [
  {
    label: '7天',
    value: 604800,
  },
  {
    label: '15天',
    value: 1296000,
  },
  {
    label: '30天',
    value: 2592000,
  },
  {
    label: '自定义',
    value: 5,
  },
];

// 1 大转盘
// 2 推广
// 3 红包
// 4 负盈利返现
// 5 自定义活动
// 6 每日投注
// 7 幸运赌注
// 8 存款
// 9 签到
// 10 代理额外日奖励
// 11 代理额外月奖励
// 12 逢8会员日
// 13 定点充值  ty值

export const activeType = {
  1: '轮盘',
  2: '推广',
  3: '抢红包',
  4: '负盈利返现',
  5: '自定义',
  6: '每日奖励',
  7: '幸运赌注',
  8: '充值',
  9: '签到活动',
  10: '代理额外日奖励',
  11: '代理额外月奖励',
  12: '逢8会员日',
  13: '定点充值',
  14: '钱包支付存款',
  15: '神秘盲盒',
};

export function getGroupLabel(group) {
  const d = memberOptions.find((item) => item.value === group);
  return d?.label;
}
